The return type of Math.random() is double, value range is 0&gt;=x&gt;1 (0 is possible). If a random integer is required, do not multiply x by 10 then round the result. The correct way is to use nextInt or nextLong method which belong to Random Object.
Examples:
<pre>
    Negative example:
    Long randomLong =(long) (Math.random() * 10);
    Positive example:
    Long randomLong = new Random().nextLong();
</pre>